import store from '@/store'
import { getModule } from '@/tools'

/**
 * @type {import('vuex').Module<AppModule.State, never>}
 */
const AppModule = {
  namespaced: true,
  state: {
    rol: [1, 2, 3, 4],
    sideBar: false
  },
  getters: {
    root: (state, getters, rootState, rootGetters) => {
      console.log(state, getters, rootState, rootGetters)
      return rootState
    }
  },
  mutations: {
    update_side_bar(state, payload) {
      state.sideBar = payload
    },
    update_rol(state, payload) {
      state.rol = payload
    }
  },
  actions: {
    async getRole(context) {
      const response = Promise.resolve([1, 2, 3, 4])
      context.commit('update_rol', response)
    }
  }
}

/**
 * @type {AppModule.State}
 */
export const appModule = getModule(store, 'appModule', AppModule)
